import 'package:bxultimate/widgets/app/app_input.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart' hide TDInput, TDInputType;

import 'controller.dart';

class ServerUrlSettingPage extends StatefulWidget {
  const ServerUrlSettingPage({Key? key}) : super(key: key);

  @override
  State<ServerUrlSettingPage> createState() => _ServerUrlSettingPageState();
}

class _ServerUrlSettingPageState extends State<ServerUrlSettingPage> {
  final controller = Get.find<ServerUrlSettingController>();
  final state = Get.find<ServerUrlSettingController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
      child: Scaffold(
        backgroundColor: Colors.transparent,
        appBar: AppBar(
          title: Text('服务地址设置'),
        ),
        body: Column(
          children: [
            TDInput(
              controller: controller.serverUrlController,
              required: true,
              maxLength: 11,
              leftLabel: '服务地址',
              type: TDInputType.special,
              textAlign: TextAlign.end,
              backgroundColor: Colors.transparent,
              hintText: '请输入服务地址',
              inputType: TextInputType.url,
            ),
            TDButton(
              text: '保存',
              onTap: controller.save,
              theme: TDButtonTheme.primary,
              isBlock: true,
            )
          ],
        ),
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<ServerUrlSettingController>();
    super.dispose();
  }
}
